package w2.onespace.controller;

import bean.UserAddress;
import com.alibaba.dubbo.config.annotation.Reference;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSort;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import w2.onespace.service.OrderService;
import w2.onespace.service.UserService;

import java.util.List;

/**
 * @Classname UseController
 * @Description TODO
 * @Date 2022/3/28 14:41
 * @Created by chenjin
 */
@Slf4j
@RestController
@Api(tags = {"消费者测试接口"}, description = "UserController")
public class UseController {
    @Autowired
    OrderService orderService;
    @Reference
    private UserService userService;
    @PostMapping("/create")
    @ApiOperationSort(value = 1)
    @ApiOperation(value = "根据id获取用户", notes = "",position = 1)
    public String create(){
        System.out.println("消费者调用");
        List<UserAddress> list = orderService.getList();
        for (UserAddress userAddress : list) {
            log.info("遍历"+userAddress);
        }
        return list.toString()+"返回结果";
    }
    @PostMapping("/delete")
    @ApiOperationSort(value = 2)
    @ApiOperation(value = "根据id删除用户", notes = "",position = 1)
    public void deleteById(){
        orderService.deleTe();
    }
}
